<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:set var="reportTitle" value="halm机测试 - 档位分布报表" scope="session"/>

<%@ include file="/common/report_head.jsp" %>
<%@ include file="/condition/sartTime_YMDH_input.html"%>
<%@ include file="/condition/endTime_YMDH_input.html"%>
<%@ include file="/condition/fab_sumo_must.html"%>
<%--<%@ include file="/condition/attributes_sumo.html"%>--%>
<%@ include file="/condition/effNo_sumo.html"%>
<%@ include file="/condition/line_sumo.html"%>
<%@ include file="/condition/toolg_sumo.html"%>
<%@ include file="/condition/toolType_radio.html"%>
<%@ include file="/condition/tool_sumo.html"%>
<%@ include file="/condition/spec_sumo.html"%>
<%@ include file="/condition/waferSpec_sumo.html"%>
<%@ include file="/condition/manufacturer_sumo.html"%>
<%@ include file="/condition/baseIdsumo.html"%>
<%@ include file="/condition/lotId_text.html"%>
<%@ include file="/condition/gear_sumo.html"%>

<%@ include file="/common/report_middle.jsp" %>
<%@ include file="/charts-grid/echarts.html"%>
<div class="col-md-12" style="height: 150px;margin-bottom: 25px;">
    <div id="pqGrid"></div>
</div>
<div class="col-md-12" style="height: 420px;margin-bottom: 25px;">
    <div id="pqGrid_detail"></div>
</div>
<%@include file="/common/report_end.jsp" %>


<script>

    $(document).ready(function () {
        $("title").text("halm机测试 - 档位分布报表");
        $("label:contains('线别:')").addClass("keyCss");

        $('#query_btn').click(function (){
            if($("#bayIdSumo").val() === null || $("#bayIdSumo").val() === '' ) { showErrorDialog("0000002", "线别为必选项"); return false; }
            initGridAndChart();
            ajax('/jn-report/report/halm_gearDistribution_report.do' ,loadConditionMapData(), true, ajax_successful);

            function ajax_successful(outTrxObj) {
                if(outTrxObj.gridData.length < 1) { showMessengerDialog("数据查询为空"); return false; }

                //Chart图数据
                if ($("#charts").length > 0) {
                    var echartsData = outTrxObj.chartsData;
                    option.title.text = echartsData.title;
                    option.legend.data = [];
                    option.legend.data = ['产出比例','累计产出比例'];
                    option.grid.right = '12%';
                    option.grid.top =  '13%';
                    option.xAxis[0].data = [];
                    option.xAxis[0].data = echartsData.xAxisData;
                    option.yAxis = [];
                    option.yAxis = [
                        {
                            type: 'value',
                            name: '产出比例',
                            max: 'dataMax',
                            splitLine:{show:false},
                            axisLabel: {formatter: '{value} %'}
                        },
                        {
                            type: 'value',
                            name: '累计产出比例',
                            min: 0,
                            max: 100,
                            interval: 10,
                            splitLine:{show:false},
                            axisLabel: {formatter: '{value} %'}
                        }
                    ];
                    option.series = [];
                    //产出比例
                    option.series.push({
                        name: "产出比例",
                        type: 'bar',
                        yAxisIndex: 0,
                        data: echartsData.seriesDatas[0],
                        barMaxWidth : 38,
                        itemStyle: {
                            normal: {
                                color: new echarts.graphic.LinearGradient(
                                    0, 0, 0, 1,
                                    [
                                        {offset: 0, color: '#51B38F'},
                                        {offset: 0.5, color: '#44AE94'},
                                        {offset: 1, color: '#45AA82'}
                                    ]
                                )
                            }
                        }
                    });
                    //累计产出比例
                    for (var i = 1; i < echartsData.seriesDatas.length; i++) {
                        option.series.push({
                            name: '累计产出比例',
                            type: 'line',
                            yAxisIndex: 1,
                            data: echartsData.seriesDatas[i],
                            itemStyle: {
                                normal: {lineStyle: {color: '#B33E65'}}
                            },
                            label: {
                                normal: {
                                    show: true,
                                    distance: 5,
                                    color: 'black',
                                    fontWeight: 'bold',
                                    formatter: '{c}%'
                                }
                            },
                            animationDelay: function (idx) {
                                return idx * 10 + 100;
                            }
                        });
                    }
                    option.backgroundColor = 'white';
                    option.grid.show = false;
                    myChart.clear();
                    myChart.setOption(option);
                }

                //grid表格数据
                if ($("#pqGrid").length > 0) {
                    var colM =[{halign:"center",align:'center', dataIndx: 'rate_type', title: '', width: 150, editable: false, sortable: true}];
                    for (var i=0; i<outTrxObj.dynamicColumn.length; i++){
                        var gear = outTrxObj.dynamicColumn[i];
                        colM.push({halign:'center', align:'center', dataIndx: gear, title: gear, width: 85, editable: false, sortable: true});
                    }
                    _pqUtil.f.setColModel($("#pqGrid"), colM);
                    _pqUtil.f.seTitle($("#pqGrid"), "halm机测试数据报表-档位分布明细数据");
                    _pqUtil.f.isShowTitle($("#pqGrid"), false);
                    _pqUtil.f.loadPqGridData($("#pqGrid"), outTrxObj.dynamicColumnJsonGridData);

                }

                //grid明细表格数据
                if ($("#pqGrid_detail").length > 0) {
                    var detail_colM = [
                        {halign:"center",align:'center', dataIndx: 'gear',	                title: '档位',            width: 200,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'count',      	        title: '档位分布',        width: 200,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'output_percent',    	title: '产出比例',        width: 200,   editable: false, sortable: true},
                        {halign:"center",align:'center', dataIndx: 'cumulative_percent',   	title: '累计产出比例',    width: 200,   editable: false, sortable: true}
                    ];
                    _pqUtil.f.setColModel($("#pqGrid_detail"), detail_colM);
                    _pqUtil.f.seTitle($("#pqGrid_detail"), "halm机测试数据报表-档位分布明细数据");
                    _pqUtil.f.isShowTitle($("#pqGrid_detail"), false);
                    _pqUtil.f.loadPqGridData($("#pqGrid_detail"), outTrxObj.gridData);
                }
            }
        });

        //$("#query_btn").after('<button id="export_btn" style="width: 80px;height: 23px;margin-top: 5px;margin-right: 10px;background-color: #F5F5F5;font-size: 14px;font: \'微软雅黑\';font-weight: bold;color: #428bca;border: 1px solid #191970;">导出</button>');
        //    $("#export_btn").click(function (){
        //        alert("到出源数据到Excel");
        //    postData(JSON.stringify(loadConditionMapData()), "halm机源数据-导出", "halm_exportExcel.do", false);
        //});
    });
</script>
